package zhongbo.java.air.flightpath.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import zhongbo.java.air.flightpath.config.RedisListenerConfig;


@Component
public class RedisLogChanelPublisher {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;


    @Bean
    RedisLogChanelPublisher createRedisLogChanelPublisher() {
        return new RedisLogChanelPublisher();
    }

    /**
     * 发布消息
     */
    public void broadcast(String message) {
        redisTemplate.convertAndSend(RedisListenerConfig.LOG_CHANEL,message);
    }

    public void toMyBroadcast(String message) {
        redisTemplate.convertAndSend(RedisListenerConfig.LIVE_FLIGHT_PATH_TANG_GUO_ZHENG,message);
    }
}